// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WindowsTestGame.cs" company="Jarno Burger">
//   see copyright.txt in the root of this project.
// </copyright>
// <summary>
//   This is the main type for your game
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WinFormsTest
{
    using GUI4UFramework.Management;

    using WinFormAdapter;

    /// <summary>
    /// This is the main type for your game.
    /// </summary>
    public class WindowsTestGame : Game
    {
        /// <summary>
        /// The test script.
        /// </summary>
        private WindowsTestScript windowsTestScript;

        /// <summary>
        /// A script that shows stars.
        /// </summary>
        private Star star;

        /// <summary>
        /// Initializes a new instance of the <see cref="WindowsTestGame"/> class.
        /// </summary>
        public WindowsTestGame()
        {
            this.Width = 1280;
            this.Height = 800;
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            this.Text = @"GUI4U";

            base.Initialize();

            this.windowsTestScript = new WindowsTestScript(this);
            this.windowsTestScript.Initialize();

            this.star = new Star(this);

            this.IsMouseVisible = true;
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            this.star.LoadContent();
            this.windowsTestScript.LoadContent();
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            this.windowsTestScript.UnloadContent();
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            this.star.Update();
            this.windowsTestScript.Update(this.CurrentTime);

            base.Update(gameTime);
        }
        
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            this.star.Draw();
            this.windowsTestScript.Draw(this.CurrentTime);

            base.Draw(gameTime);
        }
    }
}
